package com.luotat.productservice.mapper;

import com.luotat.pojo.product.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ProductMapper
{
    @Insert("INSERT INTO product (product_name, price) " +
            "VALUES (#{productName}, #{price})")
    void insert(Product product);

    @Delete("DELETE FROM product " +
            "WHERE id = #{id}")
    void delete(Integer id);

    @Update("UPDATE product " +
            "SET product_name = #{productName}, price = #{price} " +
            "WHERE id = #{id}")
    void update(Product product);

    @Select("SELECT * " +
            "FROM product " +
            "WHERE id = #{id}")
    Product getById(Integer id);

    @Select("SELECT * " +
            "FROM product")
    List<Product> getAll();
}